﻿using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Write.API.Appcation.Commands.Sign;
using MedicalPCTerminal.Write.API.Appcation.Commands.基础设置;
using MedicalPCTerminal.Write.API.Appcation.Commands.居民档案PC端;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Write.API.Controllers
{
    /// <summary>
    /// 签约控制器，处理患者签约和设备绑定相关操作
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SignController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        public SignController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 患者设备绑定信息添加
        /// </summary>
        /// <param name="request">添加设备绑定命令</param>
        /// <returns>API结果</returns>
        [HttpPost]
        public Task<APIResult<object>> AddSignDeviceBind(AddSignDeviceBindCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 患者设备绑定的删除（解绑）
        /// </summary>
        /// <param name="request">删除设备绑定命令</param>
        /// <returns>API结果</returns>
        [HttpPost]
        public async Task<APIResult<int>> DelSignDeviceBind(DelSignDeviceBindCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 患者签约的添加
        /// </summary>
        /// <param name="request">添加患者签约命令</param>
        /// <returns>API结果</returns>
        [HttpPost]
        public async Task<APIResult<object>> AddNCDSign(AddNCDSignCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
        